package com.pigs.pigsordersystem.service.impl;

import com.pigs.pigsordersystem.entity.AdminEntity;
import com.pigs.pigsordersystem.mapper.AdminMapper;
import com.pigs.pigsordersystem.service.IAdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.codec.digest.DigestUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Y.yang
 * @since 2020-03-14
 */
@Service
@Transactional
public class AdminServiceImpl extends ServiceImpl<AdminMapper, AdminEntity> implements IAdminService {

    @Autowired
    private AdminMapper adminMapper;

    /**
     * 管理员登录实现类
     *
     * @param adminAccount
     * @param adminPassword
     * @return
     */
    @Override
    public AdminEntity loginAdmin(String adminAccount, String adminPassword) {

        if (!adminAccount.isEmpty() && !adminAccount.isEmpty()) {
            String adminPassMd5 = DigestUtils.md5Hex(adminPassword);
            AdminEntity adminEntity = adminMapper.loginAdmin(adminAccount, adminPassMd5);

            return adminEntity;

        }
        return null;
    }
}
